<template>
  <div class="activity-management">
    <h2>活动管理</h2>
    <ul>
      <li v-for="activity in activities" :key="activity.id">
        {{ activity.title }}
        <button @click="deleteActivity(activity.id)">删除</button>
        <router-link :to="`/edit-activity/${activity.id}`">编辑</router-link>
      </li>
    </ul>
    <button @click="addActivity">新增活动</button>
  </div>
</template>

<script>
import activities from '../data/activities.js';

export default {
  data() {
    return {
      activities
    };
  },
  methods: {
    deleteActivity(id) {
      this.activities = this.activities.filter(a => a.id !== id);
    },
    addActivity() {
      this.$router.push('/create-activity');
    }
  }
};
</script>